//-------
// url方法
//----
jQuery.extend({
	//获取url参数为对象 
    //$.getRequest(id)
    getRequest: function (id) {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            var strs = str.split("&");
            for(var i = 0; i < strs.length; i ++) {
                theRequest[strs[i].split("=")[0]] =  decodeURI(decodeURIComponent( 
                    decodeURI(decodeURIComponent(
                        escape(strs[i].split("=")[1]).replace(/\+/g, '%20')
                    ))
                ));
            }
        }
        return id ? theRequest[id] : theRequest;
    },
    //设置url参数   
    //$.setRequest(obj)
    setRequest:function(obj){
        var param = $.extend(true,{},this.getRequest(null), obj);
        var url = param.url;
        delete param.url;
        var _url=(location.pathname).replace('//','/')+"?url="+url+"&"+$.param(param,true);
        window.location.href =encodeURI(_url);
    },
    //获取模块
    getModule:function(page){
        var src  = window.location.href.replace(window.__root__,'');
        src  = src.replace('index.php/','').replace('index.php//','');
        var srcs = src.split('/');    srcs[srcs.length-1] = (page || 'edit');
        return ('/'+ srcs.join('/')).replace('//','/');
    }
});

